package ar.edu.sovietrussia.customcomponents.bookviews;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import books.Author;
import books.BookInfo;
import books.Category;
import books.Publisher;
import dtos.AuthorDTO;
import dtos.BookInfoDTO;
import dtos.FactoryDTO;
import dtos.PublisherDTO;

/**
 */
public final class BookInfoFactory {

    private static FactoryDTO factoryDto = new FactoryDTO();

    private BookInfoFactory() {
    }

    public static List<BookInfoDTO> listBookInfoExample(final int quantity) {

        List<BookInfoDTO> list = new ArrayList<BookInfoDTO>();

        for (int i = 0; i < quantity; i++) {
            BookInfoDTO dto = new BookInfoDTO();
            dto.setAuthors(Arrays.asList(new AuthorDTO("Autor capo")));
            dto.setAvailable(true);
            dto.setCategories(Arrays.asList(Category.values()));
            dto.setIsbn("000000000000" + i);
            dto.setTitle("Title " + i);
            dto.setDescription("Description " + i);
            dto.setPublisher(new PublisherDTO("Publisher"));
            list.add(dto);
        }

        return list;
    }

    public static BookInfoDTO bookInfoExample() {
        List<Author> authors = new ArrayList<Author>();
        authors.add(new Author("Autor Copado"));
        authors.add(new Author("Batman"));

        List<Category> cat = new ArrayList<Category>();
        cat.add(Category.CLASSICS);
        cat.add(Category.GAMES);

        BookInfo info = new BookInfo("Titulo libro", "1234567891", "descripcion libro", new Publisher(
                "Editorial copada"), authors, cat);

        return factoryDto.toDto(BookInfoDTO.class, info);
    }
}
